<template>
    <div>
        <div class="breadcrumb-box">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ path: '/oemIndex' }">生产代工</el-breadcrumb-item>
                <el-breadcrumb-item>生产代工详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="line">
            <img :src="$global.Image.icon_goods_line" />
        </div>
        <div class="container">
            <div class="line-ti">
                <div>生产代工详情</div>
            </div>
            <div class="write-info-tit">{{info.name}}</div>
            <el-form ref="form" :model="form" label-width="120px">
                <el-form-item label="提交时间：">
                    <el-input :value="info.create_time" readonly placeholder="2020-02-14"></el-input>
                </el-form-item>
                <!-- <el-form-item label="用户名称：">
                    <el-input :value="info.name" readonly placeholder="用户名称"></el-input>
                </el-form-item> -->
                <el-form-item label="联系人：">
                    <el-input :value="info.contacts" readonly placeholder="请输入联系人"></el-input>
                </el-form-item>
                <el-form-item label="联系电话：">
                    <el-input :value="info.mobile" readonly placeholder="请输入联系电话"></el-input>
                </el-form-item>
                <el-form-item label="商品名称：">
                    <el-input :value="info.name" readonly placeholder="请输入商品名称"></el-input>
                </el-form-item>
                <el-form-item label="代工要求：">
                    <el-input type="textarea" readonly :value="info.content" placeholder="请输入代工要求"></el-input>
                </el-form-item>
                <el-form-item label="附件：">
                    <div class="file">
                        <div class="td-f1">
                            <div class="el-form-item__content upload-img">
                                <ul class="el-upload-list el-upload-list--picture" v-if="info.files&&info.files.length">
                                    <template v-for="(item,index) in info.files">
                                        <li :tabindex="index" class="el-upload-list__item el-upload-list__item1" :key="index" v-if="imgExt.indexOf(item.ext) !== -1">
                                            <img :src="item.src" class="el-upload-list__item-thumbnail">
                                            <a class="el-upload-list__item-name"><i class="el-icon-document"></i>{{item.name}}</a>
                                            <i class="el-icon-download" @click="download(item.src, item.name)"></i>
                                        </li>
                                        <li :tabindex="index" class="el-upload-list__item el-upload-list__item1" :key="index" v-else>
                                            <i class="el-icon-document el-upload-list__item-thumbnail" style="font-size:66px;"></i>
                                            <a class="el-upload-list__item-name"><i class="el-icon-document"></i>{{item.name}}</a>
                                            <i class="el-icon-download" @click="download(item.src, item.name)"></i>
                                        </li>
                                    </template>
                                </ul>
                                <div v-else>无附件</div>
                            </div>
                        </div>
                    </div>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="$router.go(-1)">返回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
import { articleDetail } from '@api/user';
import { downloadUrlFile } from '@/utils/download';

export default {
    data() {
        return {
            id: this.$route.params.id,
            imgExt: ['.jpg', '.jpeg', '.gif', '.png', 'jpg', 'jpeg', 'gif', 'png'],
            info: {},
            loading: false,
        };
    },
    methods:{
        getDetail(){
            let data = {
                id: this.id
            }
            if (this.loading) return;
            this.loading = true
            articleDetail(data).then(res => {
                this.info = res.data;
                this.loading = false
            });
        },
        download (url, filename) {
            downloadUrlFile(url, filename)
        }
    },
    mounted(){
        this.getDetail()
    }
};
</script>

<style scoped  lang="scss">
.line {
    width: 1200px;
    margin: 0 auto 30px;
    img {
        display: block;
        width: 100%;
    }
}
.el-input.is-readonly .el-input__inner{
    color: #333333 !important;
    background-color:#fff;
}
.el-textarea.is-readonly .el-textarea__inner{
    color: #333333 !important;
    background-color:#fff;
}
.file {
    width: 520px;
    background: #ffffff;
    border-radius: 5px;
    box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    padding: 10px 25px;
    box-sizing: border-box;
    .file-left {
        font-size: 16px;
        font-weight: bold;
        text-align: left;
        color: #333333;
        // line-height: 16px;
        // display: inline-block;
    }
    .file-right {
        flex: 1;
        display: flex;
        align-items: center;
        .no-file {
            font-size: 13px;
            color: #999999;
            margin-right: 10px;
        }
        .have-file {
            font-size: 13px;
            color: #333333;
            margin-right: 10px;
        }
        .choose-file {
            width: 88px;
            height: 24px;
            background: #e2edff;
            border: 1px solid #13479d;
            border-radius: 2px;
            font-size: 12px;
            text-align: center;
            color: #13479d;
            line-height: 24px;
            cursor: pointer;
        }
    }
}
.el-button--primary:focus,
.el-button--primary:hover {
    background: #da213d;
    border-color: #da213d;
}
.el-button--primary {
    width: 230px;
    background: #da213d;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    color: #ffffff;
    line-height: 18px;
    box-sizing: border-box;
    height: 50px;
    border-color: #da213d;
    &:hover {
        background: #da213d;
        border-color: #da213d;
    }
    &:active {
        background: #da213d;
        border-color: #da213d;
    }
}
.el-input {
    width: 520px;
}
.el-form-item {
    margin-top: 20px;
}
.el-form-item__label {
    text-align: right;
    font-size: 15px;
    // font-weight: bold;
    padding-left: 25px;
}
.el-textarea__inner {
    width: 520px;
    resize: none;
    height: 80px;
}
.write-info-tit {
    position: relative;
    font-size: 18px;
    font-weight: bold;
    height: 90px;
    padding-left: 24px;
    display: flex;
    align-items: center;
    color: #333333;
    border-bottom: 1px dashed #eaecfa;
    &::before {
        border-radius: 100%;
        border: 3px solid #da213d;
        position: absolute;
        width: 5px;
        height: 5px;
        left: 0;
        top: 0;
        bottom: 0;
        margin: auto 0;
        content: "";
    }
}
.line-ti {
    width: 100%;
    border-bottom: 1px solid #dbdbdb;
    display: flex;
    > div {
        color: #da213d;
        font-size: 18px;
        // border-bottom: 3px solid $color;
        // width: 112px;
        line-height: 36px;
        font-weight: bold;
        position: relative;
        &::before {
            position: absolute;
            bottom: 0;
            left: 0;
            content: "";
            width: 72px;
            height: 3px;
            background: #da213d;
        }
    }
}
.el-upload-list__item1 {
    .el-icon-download {
        position: absolute;
        top: 5px;
        right: 5px;
        cursor: pointer;
        opacity: .75;
        color: #606266;
    }
}
</style>